﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ItemView.aspx.cs" Inherits="Directory.Web.ItemView"
    Theme="Default" MasterPageFile="~/DefaultMasterPage.master" %>

<%@ Register TagName="CategoryChilds" TagPrefix="DirectoryControl" Src="~/Controls/CategoryChilds.ascx" %>
<asp:Content ContentPlaceHolderID="head" runat="server">
    <title>
        <% = Directory.Web.WebSettings.GetInstance().SiteName %>
        —
        <% = currentCategory.CategoryName %></title>
    <script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
	<script type="text/javascript">
		
	</script>
    <script type="text/javascript">
        /*function $(id) {
            return document.getElementById(id);
        }*/
        function ShowItemPage() {
            document.getElementById('ItemView').style.display = 'none';
            document.getElementById('ViewPage').style.display = '';
            return true;
        }
        function ResetPage() {
            document.getElementById('ItemView').style.display = '';
            document.getElementById('ViewPage').style.display = 'none';
            document.getElementById('itemViewFrame').setAttribute('src', 'about:blank');
        }         
    </script>	
</asp:Content>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="main_search">
        <DirectoryControl:SearchBar runat="server" ID="SearchBar" />
    </div>
</asp:Content>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <div id="ItemView" class="resizableArea">
        <div class="sider_contro">
            <div id="resizeLeftSide" class="FL sub_content">
                <DirectoryControl:CategoryNavTree ID="CategoryNavTree" runat="server" NavigateUrl="~/ItemView.aspx?" />
            </div>
            <div id="splitter" class="splitter" title="双击可在隐藏和显示之间切换。">
                <div class="LibC_lib_grippy">
                </div>
            </div>
        </div>
        <div id="resizeRightSide" class="FR main_content">
            <div class="local">
                <p class="addUrl">
                    <strong class="FR"><a href="additem.aspx?categoryId=<% = this.categoryId.ToString() %>">添加条文</a></strong>
                </p>
                <p>
                    <strong>当前位置</strong>
                    <asp:Repeater ID="rptCategoryNav" runat="server">
                        <HeaderTemplate>
                            <a href="Default.aspx">首页</a></HeaderTemplate>
                        <ItemTemplate>
                            »<a href="itemview.aspx?categoryId=<%# Eval("CategoryId") %>"><%# Eval("CategoryName") %></a>
                        </ItemTemplate>
                    </asp:Repeater>
                </p>                
            </div>
            <DirectoryControl:CategoryChilds ID="CateogryChilds" runat="server" />
            <div class="content_list">
                <asp:Repeater ID="rptItemsList" runat="server">
                    <HeaderTemplate>
                        <ol>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <li>
                            <p class="list_title">
                                <strong><%# this.pageIndex*this.pageSize + Container.ItemIndex + 1 %>.</strong><a href="<%# Eval("LinkUrl") %>"
                                    onclick="return(ShowItemPage());" target="itemViewFrame">
                                    <%# Eval("Title")%></a> &nbsp;-&nbsp;
                                <%# Eval("LinkUrl") %>
                            </p>
                            <div class="compress">
                                <p class="ico">
                                    <a href="<%# Eval("LinkUrl") %>" onclick="return(ShowItemPage());" target="itemViewFrame">                                    
                                        <img src="<%# Eval("LogoPath")%>"  onerror="this.style.display='none'"/>
                                     </a>
                                </p>
                                <div><%# Eval("Description") == null ? "" : Eval("Description").ToString().Replace("\n", "<br />") %></div>
                            </div>
                        </li>
                    </ItemTemplate>
                    <FooterTemplate>
                        </ol></FooterTemplate>
                </asp:Repeater>
            </div>
            <p class="pageBreake">
                <asp:HyperLink ID="hplFirstPage" runat="server">第一页</asp:HyperLink>&nbsp;
                <asp:HyperLink ID="hplPrePage" runat="server">上一页</asp:HyperLink>&nbsp; 第&nbsp;<asp:Label
                    ID="lbCurrentPage" runat="server" Text=""></asp:Label>&nbsp;页&nbsp;
                <asp:HyperLink ID="hplNextPage" runat="server">下一页</asp:HyperLink>&nbsp;
                <asp:HyperLink ID="hplLastPage" runat="server">最后一页</asp:HyperLink>&nbsp; 共&nbsp;<% = this.itemsRecords.ToString() %>&nbsp;条
            </p>
        </div>
    </div>
    <div id="ViewPage" style="display: none">
        <p>
            <input type="button" onclick="ResetPage()" value="返回" class="input_Button" />
        </p>
        <iframe id="itemViewFrame" name="itemViewFrame" frameborder="0" style="border: solid 1px #cccccc;overflow-x:hidden;" width="100%" height="600px"></iframe>
    </div>

    <script type="text/javascript">
        var hidenTreeKey = "hideTree";
        var leftWidth = document.getElementById('splitter').parentNode.clientWidth;
        var rightWidth = document.getElementById('resizeRightSide').clientWidth;
        document.getElementById('splitter').ondblclick = function minizeTree() {
            if (this.parentNode.clientWidth == this.clientWidth) {
                resizeBothSides(leftWidth, rightWidth);
                SetCookie(hidenTreeKey, false);
            } else {
                resizeBothSides(0, parseInt(leftWidth) + parseInt(rightWidth));
                SetCookie(hidenTreeKey, true);
            }
        }
        function resizeBothSides(left, right) {
            document.getElementById('splitter').parentNode.style.width = parseInt(document.getElementById('splitter').clientWidth) + parseInt(left) + 'px';
            document.getElementById('resizeLeftSide').style.width = parseInt(document.getElementById('splitter').parentNode.clientWidth) - parseInt(document.getElementById('splitter').clientWidth) + 'px';
            document.getElementById('resizeRightSide').style.width = parseInt(right) + 'px';
        }
        function getCookie(cookie_name) {
            var allcookies = document.cookie;
            var cookie_pos = allcookies.indexOf(cookie_name);

            if (cookie_pos != -1) {
                cookie_pos += cookie_name.length + 1;
                var cookie_end = allcookies.indexOf(";", cookie_pos);

                if (cookie_end == -1) {
                    cookie_end = allcookies.length;
                }

                var value = unescape(allcookies.substring(cookie_pos, cookie_end));
            }

            return value;
        }
        function SetCookie(name, value) {
            var expdate = new Date();
            var argv = SetCookie.arguments;
            var argc = SetCookie.arguments.length;
            var expires = (argc > 2) ? argv[2] : null;
            var path = (argc > 3) ? argv[3] : null;
            var domain = (argc > 4) ? argv[4] : null;
            var secure = (argc > 5) ? argv[5] : false;
            if (expires != null) expdate.setTime(expdate.getTime() + (expires * 1000));
            document.cookie = name + "=" + escape(value) + ((expires == null) ? "" : ("; expires=" + expdate.toGMTString()))
+ ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain))
+ ((secure == true) ? "; secure" : "");
        }
        if (getCookie(hidenTreeKey) == 'true') {
            resizeBothSides(0, parseInt(leftWidth) + parseInt(rightWidth));
        }
    </script>

</asp:Content>
